#ifndef CLIENT_H
#define CLIENT_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <tools.h>
#include <stdbool.h>
#include <stdint.h>


#define PATH_DATA "number"
#define PATH_ACC "./data/"

#define ACCONT_OPEN     1           //开户
#define ACCONT_SAVE     2           //存钱
#define ACCONT_TAKE     3           //取钱
#define ACCONT_QUERY    4           //查询
#define ACCONT_LOGIN    5           //登录
#define ACCONT_TRANS    6           //转账
#define ACCONT_UNLOCK   7           //解锁
#define ACCONT_MODIFY   8           //改密码
#define ACCONT_DESTROY  9           //销户


typedef struct Accont   //账户基本信息
{
    float balance;      //金额
    uint32_t id;          //卡号
    uint32_t lock_times;  //锁定次数(每天有三次密码错误机会，如一天错三次，账号则会被锁定)
    char name[10];      //用户名
    char pswd[10];      //密码
    bool flag_lock;     //是否锁定
}Accont;

typedef struct Client_Msg{          //客户端发送给服务段的数据
    uint32_t type;        //区分不同的业务
    Accont acc;         //账户信息
    char buf[50];       //更改信息以及退出
}Client_Msg;

void open_acc(int cli_fd);      //开户
void login_acc(int cli_fd);     //登录

void login_menu();

void login_main(int cli_fd,Accont* acc);    //登录后的主界面

void save_money(int cli_fd,Accont* acc);

void take_money(int cli_fd,Accont* acc);

void trans_money(int cli_fd,Accont* acc);

void query_acc(int cli_fd,Accont* acc);

void change_pswd(int cli_fd,Accont* acc);

void destroy_acc(int cli_fd,Accont* acc);

void unlock(int cli_fd);

#endif //CLIENT_H
